;;; GNU Guix --- Functional package management for GNU
;;;
;;; Copyright © 2022 jgart <jgart@dismail.de>
;;; This file is not part of GNU Guix.
;;;
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; GNU Guix is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.

(define-module (guixrus packages babi)
  #:use-module (guix build-system python)
  #:use-module (guix build-system gnu)
  #:use-module (guix download)
  #:use-module (guix git-download)
  #:use-module ((guix licenses) #:prefix license:)
  #:use-module (guix packages)
  #:use-module (guix utils)
  #:use-module (gnu packages)
  #:use-module (gnu packages autotools)
  #:use-module (gnu packages check)
  #:use-module (gnu packages libffi)
  #:use-module (gnu packages python-build)
  #:use-module (gnu packages python-check)
  #:use-module (gnu packages python)
  #:use-module (gnu packages python-crypto)
  #:use-module (gnu packages python-science)
  #:use-module (gnu packages python-web)
  #:use-module (gnu packages sphinx)
  #:use-module (gnu packages textutils)
  #:use-module (gnu packages python-xyz))

(define-public babi
  (package
    (name "babi")
    (version "1.5.3")
    (source (origin
              (method url-fetch)
              (uri (pypi-uri "babi" version))
              (sha256
               (base32
                "0lxa32naxgzrls8zj3p0fyqvlidzwkhcg78pv58aamxvnx1gx7v0"))))
    (build-system python-build-system)
    (propagated-inputs 
      (list python-babi-grammars 
            python-identify
            python-importlib-metadata 
            python-onigurumacffi))
    (home-page "https://github.com/asottile/babi")
    (synopsis "a text editor")
    (description "a text editor")
    (license license:expat)))
  
(define-public python-babi-grammars
  (package
    (name "python-babi-grammars")
    (version "0.0.43")
    (source (origin
              (method url-fetch)
              (uri (pypi-uri "babi_grammars" version))
              (sha256
               (base32
                "1830a57dxq9hyqiy6j6z86dm866v0zsyjpfdxsxm71387i6qcaj2"))))
    (build-system python-build-system)
    (home-page "https://github.com/asottile/babi-grammars")
    (synopsis "grammars for babi")
    (description "grammars for babi")
    (license license:expat)))

(define-public python-onigurumacffi
  (package
    (name "python-onigurumacffi")
    (version "1.2.0")
    (source (origin
              (method url-fetch)
              (uri (pypi-uri "onigurumacffi" version))
              (sha256
               (base32
                "1rfgzfjgkn68mpa4pwwrwsi8rdf43sbb23439sbs9dglmw93qgp7"))))
    (build-system python-build-system)
    (native-inputs (list oniguruma))
    (propagated-inputs (list python-cffi))
    (home-page "https://github.com/asottile/onigurumacffi")
    (synopsis "python cffi bindings for the oniguruma regex engine")
    (description "python cffi bindings for the oniguruma regex engine")
    (license license:expat)))

(define-public oniguruma
  (package
    (name "oniguruma")
    (version "6.9.8")
    (source
      (origin
        (method git-fetch)
        (uri
         (git-reference
          (url "https://github.com/kkos/oniguruma")
          (commit (string-append "v" version))))
        (file-name (git-file-name name version))
        (sha256
         (base32 "0p0j9llqq1r6f33wjj5bmrzs5wxbssxywda08z1g58ks31v5k8gi"))))
    (build-system gnu-build-system)
    (native-inputs
      (list autoconf automake libtool))
    (arguments
      ;; todo why do we need --enable-binary-compatible-posix-api=yes
      '(#:configure-flags '("--disable-static"
                            "--enable-binary-compatible-posix-api=yes")))
    (home-page "https://github.com/kkos/oniguruma")
    (synopsis "Regular expression library")
    (description
"Oniguruma is a regular expressions library.  The special characteristic
of this library is that different character encoding for every regular
expression object can be specified.")
    (license license:bsd-2)))


